# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=libteam
pkgname=(libteam libteam-docs)
pkgver=1.32
pkgrel=1
pkgdesc="Library for controlling team network device"
url="http://libteam.org/"
arch=(loong64 x86_64)
license=(LGPL)
depends=(
  bash
  jansson
  libdaemon
  libdbus
  libnl
  zeromq
)
makedepends=(
  doxygen
  git
  graphviz
)
_commit=8b843e93cee1dab61fb79b01791201cdad45e1d1  # tags/v1.32
source=("git+https://github.com/jpirko/libteam#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd libteam
  git describe --tags | sed 's/^v//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd libteam
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  local configure_options=(
    --prefix=/usr
    --sysconfdir=/etc
    --localstatedir=/var
    --libexecdir=/usr/lib
    --disable-static
  )

  cd libteam
  ./configure "${configure_options[@]}"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make all html
}

check() {
  cd libteam
  make check
}

package_libteam() {
  provides=(libteam.so libteamdctl.so)

  cd libteam
  make DESTDIR="$pkgdir" install

  install -Dt "$pkgdir/usr/lib/systemd/system" -m644 teamd/redhat/systemd/teamd@.service
  install -Dt "$pkgdir/usr/share/dbus-1/system.d" -m644 teamd/dbus/teamd.conf
}

package_libteam-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mkdir -p "$pkgdir/usr/share/doc/$pkgbase"
  cp -a libteam/doc/api "$pkgdir/usr/share/doc/$pkgbase"
}

# vim:set sw=2 sts=-1 et:
